package com.dc.refactoring._1_重新组织函数._9_SubstituteAlgorithm;

import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: 替换算法
 * @author: gdc
 * @date: 2020/11/13
 * @version 1.0
 */
public class Test {

    public String fun1(List<String> nameList) {
        for (String name : nameList) {
            if ("Don".equals(name)) {
                return "Don";
            }
            if ("John".equals(name)) {
                return "John";
            }
            if ("Kent".equals(name)) {
                return "Kent";
            }
        }
        return "";
    }

    public String fun2(List<String> nameList) {
        ArrayList<Object> paramList = Lists.newArrayList("Don", "John", "Kent");
        for (String name : nameList) {
            if (paramList.contains(name)) {
                return name;
            }
        }
        return "";
    }

}
